package com.geping.etl.common.security.authentication.impl;

import com.geping.etl.common.security.authentication.AuthOrder;
import com.geping.etl.common.security.authentication.AuthOrderConstant;
import com.geping.etl.common.security.authentication.AuthServiceContainer;
import com.geping.etl.common.security.authentication.BasicAuthService;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;

@Service
public class SessionAuthServiceImpl extends AuthServiceContainer implements BasicAuthService, AuthOrder,Comparable<AuthOrder>{


    /**
     * 登录状态鉴权
     * @param url
     * @return
     */
    @Override
    public boolean auth(String url,  HttpServletRequest request) {
        if (url.endsWith("userOut")||url.endsWith("home") ||url.endsWith("editPasswordSys_User")||url.endsWith("checkPwd")){
            return request.getSession().getAttribute("sys_User")!=null;
        }
        return false;
    }


    @Override
    public int getOrder() {
        return AuthOrderConstant.sessionAuthService;
    }

    @Override
    public int compareTo(AuthOrder o) {
        return this.getOrder()-o.getOrder();
    }
}